package gamble.qna.command;

import gamble.qna.dao.BoardDaoImp;
import gamble.qna.vo.BoardVO;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;


public class DeleteController {
	
private BoardDaoImp dao;
	
	public void setDao(BoardDaoImp dao) {
		this.dao = dao;
	}

	@RequestMapping("delete.js")
	protected String delete(HttpServletRequest req,BoardVO vo) {
		
		//String currentPage=req.getParameter("currentPage");
		
		vo=dao.getView(vo.getNum());
		ModelAndView mv=new ModelAndView();
		mv.addObject("vo",vo);
		//mv.addObject("currentPage", currentPage);
		mv.setViewName("deleteForm");
		
		int del=(Integer.parseInt(req.getParameter("num")));
		
		
		dao.delete(del);
		
		return "redirect:/list.js";
	}

}